//
//  UIButton+TYZAdd.m
//  tangbinWeibo
//
//  Created by 唐斌 on 2017/1/9.
//  Copyright © 2017年 唐斌. All rights reserved.
//

#import "UIButton+TYZAdd.h"
#import "TYZKitMacro.h"
#import "NSString+TYZAdd.h"

TYZSYNTH_DUMMY_CLASS(UIButton_TYZAdd)


@implementation UIButton (TYZAdd)

+ (instancetype)textWithButton:(NSString *)title fontSize:(CGFloat)fontSize normalColor:(UIColor *)normalColor highlightedColor:(UIColor *)highlightedColor
{
    
    float width = [title widthForFont:tyz_fontSize(fontSize) height:30];
    CGRect frame = CGRectMake(0.0, 0.0, width, 30);
    UIButton *button = [[UIButton alloc] initWithFrame:frame];
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:normalColor forState:UIControlStateNormal];
    [button setTitleColor:highlightedColor forState:UIControlStateHighlighted];
    [button setTitleColor:highlightedColor forState:UIControlStateSelected];
    button.titleLabel.font = tyz_fontSize(fontSize);
    return button;
}

+ (instancetype)textWithButton:(NSString *)title fontSize:(CGFloat)fontSize normalColor:(UIColor *)normalColor highlightedColor:(UIColor *)highlightedColor backgroundImageName:(NSString *)backgroundImageName
{
    float width = [title widthForFont:tyz_fontSize(fontSize) height:30];
    CGRect frame = CGRectMake(0.0, 0.0, width, 30);
    UIButton *button = [[UIButton alloc] initWithFrame:frame];
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:normalColor forState:UIControlStateNormal];
    [button setTitleColor:highlightedColor forState:UIControlStateHighlighted];
    [button setTitleColor:highlightedColor forState:UIControlStateSelected];
    button.titleLabel.font = tyz_fontSize(fontSize);
    [button setBackgroundImage:[UIImage imageNamed:backgroundImageName] forState:UIControlStateNormal];
    return button;
}

@end
